package com.zgy.myshellcommand.config;


import net.schmizz.sshj.SSHClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class SSHConfig {

    @Autowired
    private SSHUser sshUser;

    @Bean
    SSHClient sshClient() throws IOException {
        SSHClient sshClient = new SSHClient();
        sshClient.loadKnownHosts();
        sshClient.connect(sshUser.getIp());
        sshClient.authPassword(sshUser.getUser(), sshUser.getPasswd());
        return sshClient;
    }


}
